fix: reject unsupported configuration options - #43
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughConfiguration types, schemas, validation, runtime wiring, presets, examples, documentation, and tests were updated to reject unsupported options, enforce hybrid routing and redaction, and retain only supported lifecycle and tooling controls. ChangesConfiguration Contract Enforcement
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant ConfigFile
participant miftahConfigSchema
participant validateConfig
participant Runtime
ConfigFile->>miftahConfigSchema: submit configuration
miftahConfigSchema->>validateConfig: return parsed data or unsupported-option errors
validateConfig->>Runtime: provide validated configuration
Possibly related issues
Poem
Caution Pre-merge checks failedPlease resolve all errors before merging. Addressing warnings is optional.
❌ Failed checks (1 error)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
|
@coderabbitai review |
✅ Action performedReview finished.
|
✅ Action performedReview finished.
|
There was a problem hiding this comment.
Actionable comments posted: 4
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/upstream/upstream-process-manager.ts (1)
40-43: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick winDefault
startupTimeoutMsis being overwritten
...optionscomes after the fallback, so whencreateRuntimepasses{ startupTimeoutMs: undefined }, the default30_000is lost andwithTimeout(..., undefined)uses a ~1ms timer in Node. Move the spread before the fallback, or omit the key when it’s unset.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/upstream/upstream-process-manager.ts` around lines 40 - 43, In the constructor’s `this.options` initialization, the trailing `...options` overwrites the `startupTimeoutMs` fallback when the property is undefined. Spread `options` before assigning `startupTimeoutMs: options.startupTimeoutMs ?? 30_000`, preserving the default used by `withTimeout`.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@CHANGELOG.md`:
- Line 15: Update the breaking-change entry in CHANGELOG.md to document all
newly rejected profile fields, including profiles.default.metadata and
per-upstream transport, command, and url overrides, or link to the complete
configuration-boundaries documentation alongside the existing profile matcher
reference.
In `@docs/config.md`:
- Line 13: The documentation statement about upstream-specific `headers`
overrides incorrectly classifies all header values as non-secret; revise it to
limit non-secret classification to explicitly non-sensitive header values and
preserve secret-redaction guidance for authorization tokens and API keys.
In `@src/config/schema.ts`:
- Around line 114-120: Ensure unsupported process options are diagnosed before
typed validation: update the schema around rejectUnsupportedOption and
process.restartOnCrash to inspect raw values or defer their parsing with
z.unknown(), then emit UNSUPPORTED_CONFIG_OPTION via superRefine instead of
CONFIG_SCHEMA_INVALID; add a regression test covering the string value "true".
In `@tests/config-schema-contract.test.ts`:
- Around line 58-91: Extend the published config schema contract test to verify
that the generated security schema omits the runtime-rejected
requireProfileSwitchConfirmation field. Add the assertion alongside the existing
security checks in the test covering generateConfigSchema and the security
properties.
---
Outside diff comments:
In `@src/upstream/upstream-process-manager.ts`:
- Around line 40-43: In the constructor’s `this.options` initialization, the
trailing `...options` overwrites the `startupTimeoutMs` fallback when the
property is undefined. Spread `options` before assigning `startupTimeoutMs:
options.startupTimeoutMs ?? 30_000`, preserving the default used by
`withTimeout`.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 835a9422-7be9-4148-a90c-dd9040ca8a7d
📒 Files selected for processing (15)
CHANGELOG.mdREADME.mddocs/config.mdexamples/github.miftah.jsonexamples/multi-upstream.miftah.jsonsrc/cli/main.tssrc/config/generate-json-schema.tssrc/config/presets.tssrc/config/schema.tssrc/config/types.tssrc/config/validate-config.tssrc/upstream/upstream-process-manager.tssrc/utils/errors.tstests/config-runtime-parity.test.tstests/config-schema-contract.test.ts
💤 Files with no reviewable changes (1)
- examples/multi-upstream.miftah.json
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
@coderabbitai review |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/config/schema.ts (1)
147-169: 🎯 Functional Correctness | 🟠 MajorApply unsupported-option diagnostics consistently to every rejected field.
Only
process.*fields were widened toz.unknown(). Values such asprofiles.*.metadata: "x",routing.plugins: {}, orsecurity.requireProfileSwitchConfirmation: "true"still fail strict inner parsing before.superRefine()runs, producingCONFIG_SCHEMA_INVALIDinstead of the promisedUNSUPPORTED_CONFIG_OPTIONwith the exact path. Use the same raw-value/pre-parse strategy for all rejected options and add malformed-value regression tests.Also applies to: 171-224
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/config/schema.ts` around lines 147 - 169, Unsupported-option checks must run before strict parsing for every rejected field, not only process.*. Update the schema’s raw-value/pre-parse handling and related superRefine logic around profile metadata, routing plugins/match, upstream overrides, and security.requireProfileSwitchConfirmation so malformed values produce UNSUPPORTED_CONFIG_OPTION with the exact path. Add regression tests covering invalid values such as profiles.*.metadata, routing.plugins, and security.requireProfileSwitchConfirmation.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@src/config/schema.ts`:
- Around line 147-169: Unsupported-option checks must run before strict parsing
for every rejected field, not only process.*. Update the schema’s
raw-value/pre-parse handling and related superRefine logic around profile
metadata, routing plugins/match, upstream overrides, and
security.requireProfileSwitchConfirmation so malformed values produce
UNSUPPORTED_CONFIG_OPTION with the exact path. Add regression tests covering
invalid values such as profiles.*.metadata, routing.plugins, and
security.requireProfileSwitchConfirmation.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 00193d0a-0d83-49fd-88b3-c1152642d697
📒 Files selected for processing (7)
CHANGELOG.mddocs/config.mdsrc/config/schema.tssrc/upstream/upstream-process-manager.tstests/config-runtime-parity.test.tstests/config-schema-contract.test.tstests/upstream-manager.test.ts
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
@coderabbitai review |
✅ Action performedReview finished.
|
Summary
UNSUPPORTED_CONFIG_OPTIONdiagnostics.Validation
npm test(88 tests)npm run typechecknpm run lintnpm run buildnode dist/cli/main.js schemanpm run check:packvalidateanddoctorrejection checks forprocess.restartOnCrashRelates to #4
Summary by CodeRabbit
UNSUPPORTED_CONFIG_OPTION, including the exact failing config path.transport/command/urloverrides are rejected; only supported override fields remain.process.startupTimeoutMs.